package com.ity.teamanagement.aspect;

import com.ity.teamanagement.utils.RedisUtils;
import lombok.extern.log4j.Log4j2;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author coderFu
 * @create 2021/5/23
 * AOP织入切面，进行鉴权
 */
@Aspect
@Component
@Log4j2
public class InterFaceAspect {

    @Autowired
    private HttpServletRequest request;

    @Autowired
    private RedisUtils redisUtils;

    @Before(value = "@annotation(com.ity.teamanagement.annocation.CheckAuthorityStatus)")
    public void CheckAuthorityStatus(JoinPoint joinPoint) throws Throwable{
        System.out.println(joinPoint);
        redisUtils.checkAuthorityStatus(request);
    }

    @Before(value = "@annotation(com.ity.teamanagement.annocation.CheckLoginState)")
    public void CheckLoginState(JoinPoint joinPoint) throws Throwable{
        System.out.println(joinPoint);
        redisUtils.checkLoginState(request);
    }


}
